

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="Description" content="scikit-learn: machine learning in Python">

  
  <title>sklearn.svm.NuSVC &mdash; scikit-learn 0.22 documentation</title>
  
  <link rel="canonical" href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.NuSVC.html" />

  
  <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  <link rel="stylesheet" href="../../_static/css/vendor/bootstrap.min.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script> 
</head>
<body>
<nav id="navbar" class="sk-docs-navbar navbar navbar-expand-md navbar-light bg-light py-0">
  <div class="container-fluid sk-docs-container px-0">
      <a class="navbar-brand py-0" href="../../index.html">
        <img
          class="sk-brand-img"
          src="../../_static/scikit-learn-logo-small.png"
          alt="logo"/>
      </a>
    <button
      id="sk-navbar-toggler"
      class="navbar-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="sk-navbar-collapse collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../install.html">Install</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../user_guide.html">User Guide</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../classes.html">API</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="../../auto_examples/index.html">Examples</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../getting_started.html">Getting Started</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../tutorial/index.html">Tutorial</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../glossary.html">Glossary</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../developers/index.html">Development</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../faq.html">FAQ</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../related_projects.html">Related packages</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../roadmap.html">Roadmap</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="../../about.html">About us</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
        </li>
        <li class="nav-item dropdown nav-more-item-dropdown">
          <a class="sk-nav-link nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="sk-nav-dropdown-item dropdown-item" href="../../getting_started.html">Getting Started</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../tutorial/index.html">Tutorial</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../glossary.html">Glossary</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../developers/index.html">Development</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../faq.html">FAQ</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../related_projects.html">Related packages</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../roadmap.html">Roadmap</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="../../about.html">About us</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
          </div>
        </li>
      </ul>
      <div id="searchbox" role="search">
          <div class="searchformwrapper">
          <form class="search" action="../../search.html" method="get">
            <input class="sk-search-text-input" type="text" name="q" aria-labelledby="searchlabel" />
            <input class="sk-search-text-btn" type="submit" value="Go" />
          </form>
          </div>
      </div>
    </div>
  </div>
</nav>
<div class="d-flex" id="sk-doc-wrapper">
    <input type="checkbox" name="sk-toggle-checkbox" id="sk-toggle-checkbox">
    <label id="sk-sidemenu-toggle" class="sk-btn-toggle-toc btn sk-btn-primary" for="sk-toggle-checkbox">Toggle Menu</label>
    <div id="sk-sidebar-wrapper" class="border-right">
      <div class="sk-sidebar-toc-wrapper">
        <div class="sk-sidebar-toc-logo">
          <a href="../../index.html">
            <img
              class="sk-brand-img"
              src="../../_static/scikit-learn-logo-small.png"
              alt="logo"/>
          </a>
        </div>
        <div class="btn-group w-100 mb-2" role="group" aria-label="rellinks">
            <a href="sklearn.svm.LinearSVR.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="sklearn.svm.LinearSVR">Prev</a><a href="../classes.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="API Reference">Up</a>
            <a href="sklearn.svm.NuSVR.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="sklearn.svm.NuSVR">Next</a>
        </div>
        <div class="alert alert-danger p-1 mb-2" role="alert">
          <p class="text-center mb-0">
          <strong>scikit-learn 0.22</strong><br/>
          <a href="http://scikit-learn.org/dev/versions.html">Other versions</a>
          </p>
        </div>
        <div class="alert alert-warning p-1 mb-2" role="alert">
          <p class="text-center mb-0">
            Please <a class="font-weight-bold" href="../../about.html#citing-scikit-learn"><string>cite us</string></a> if you use the software.
          </p>
        </div>
          <div class="sk-sidebar-toc">
            <ul>
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sklearn.svm</span></code>.NuSVC</a><ul>
<li><a class="reference internal" href="#examples-using-sklearn-svm-nusvc">Examples using <code class="docutils literal notranslate"><span class="pre">sklearn.svm.NuSVC</span></code></a></li>
</ul>
</li>
</ul>

          </div>
      </div>
    </div>
    <div id="sk-page-content-wrapper">
      <div class="sk-page-content container-fluid body px-md-3" role="main">
        
  <div class="section" id="sklearn-svm-nusvc">
<h1><a class="reference internal" href="../classes.html#module-sklearn.svm" title="sklearn.svm"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sklearn.svm</span></code></a>.NuSVC<a class="headerlink" href="#sklearn-svm-nusvc" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="sklearn.svm.NuSVC">
<em class="property">class </em><code class="sig-prename descclassname">sklearn.svm.</code><code class="sig-name descname">NuSVC</code><span class="sig-paren">(</span><em class="sig-param">nu=0.5</em>, <em class="sig-param">kernel='rbf'</em>, <em class="sig-param">degree=3</em>, <em class="sig-param">gamma='scale'</em>, <em class="sig-param">coef0=0.0</em>, <em class="sig-param">shrinking=True</em>, <em class="sig-param">probability=False</em>, <em class="sig-param">tol=0.001</em>, <em class="sig-param">cache_size=200</em>, <em class="sig-param">class_weight=None</em>, <em class="sig-param">verbose=False</em>, <em class="sig-param">max_iter=-1</em>, <em class="sig-param">decision_function_shape='ovr'</em>, <em class="sig-param">break_ties=False</em>, <em class="sig-param">random_state=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/svm/_classes.py#L656"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC" title="Permalink to this definition">¶</a></dt>
<dd><p>Nu-Support Vector Classification.</p>
<p>Similar to SVC but uses a parameter to control the number of support
vectors.</p>
<p>The implementation is based on libsvm.</p>
<p>Read more in the <a class="reference internal" href="../svm.html#svm-classification"><span class="std std-ref">User Guide</span></a>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>nu</strong><span class="classifier">float, optional (default=0.5)</span></dt><dd><p>An upper bound on the fraction of training errors and a lower
bound of the fraction of support vectors. Should be in the
interval (0, 1].</p>
</dd>
<dt><strong>kernel</strong><span class="classifier">string, optional (default=’rbf’)</span></dt><dd><p>Specifies the kernel type to be used in the algorithm.
It must be one of ‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’ or
a callable.
If none is given, ‘rbf’ will be used. If a callable is given it is
used to precompute the kernel matrix.</p>
</dd>
<dt><strong>degree</strong><span class="classifier">int, optional (default=3)</span></dt><dd><p>Degree of the polynomial kernel function (‘poly’).
Ignored by all other kernels.</p>
</dd>
<dt><strong>gamma</strong><span class="classifier">{‘scale’, ‘auto’} or float, optional (default=’scale’)</span></dt><dd><p>Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’.</p>
<ul class="simple">
<li><p>if <code class="docutils literal notranslate"><span class="pre">gamma='scale'</span></code> (default) is passed then it uses
1 / (n_features * X.var()) as value of gamma,</p></li>
<li><p>if ‘auto’, uses 1 / n_features.</p></li>
</ul>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 0.22: </span>The default value of <code class="docutils literal notranslate"><span class="pre">gamma</span></code> changed from ‘auto’ to ‘scale’.</p>
</div>
</dd>
<dt><strong>coef0</strong><span class="classifier">float, optional (default=0.0)</span></dt><dd><p>Independent term in kernel function.
It is only significant in ‘poly’ and ‘sigmoid’.</p>
</dd>
<dt><strong>shrinking</strong><span class="classifier">boolean, optional (default=True)</span></dt><dd><p>Whether to use the shrinking heuristic.</p>
</dd>
<dt><strong>probability</strong><span class="classifier">boolean, optional (default=False)</span></dt><dd><p>Whether to enable probability estimates. This must be enabled prior
to calling <code class="docutils literal notranslate"><span class="pre">fit</span></code>, will slow down that method as it internally uses
5-fold cross-validation, and <code class="docutils literal notranslate"><span class="pre">predict_proba</span></code> may be inconsistent with
<code class="docutils literal notranslate"><span class="pre">predict</span></code>. Read more in the <a class="reference internal" href="../svm.html#scores-probabilities"><span class="std std-ref">User Guide</span></a>.</p>
</dd>
<dt><strong>tol</strong><span class="classifier">float, optional (default=1e-3)</span></dt><dd><p>Tolerance for stopping criterion.</p>
</dd>
<dt><strong>cache_size</strong><span class="classifier">float, optional</span></dt><dd><p>Specify the size of the kernel cache (in MB).</p>
</dd>
<dt><strong>class_weight</strong><span class="classifier">{dict, ‘balanced’}, optional</span></dt><dd><p>Set the parameter C of class i to class_weight[i]*C for
SVC. If not given, all classes are supposed to have
weight one. The “balanced” mode uses the values of y to automatically
adjust weights inversely proportional to class frequencies as
<code class="docutils literal notranslate"><span class="pre">n_samples</span> <span class="pre">/</span> <span class="pre">(n_classes</span> <span class="pre">*</span> <span class="pre">np.bincount(y))</span></code></p>
</dd>
<dt><strong>verbose</strong><span class="classifier">bool, default: False</span></dt><dd><p>Enable verbose output. Note that this setting takes advantage of a
per-process runtime setting in libsvm that, if enabled, may not work
properly in a multithreaded context.</p>
</dd>
<dt><strong>max_iter</strong><span class="classifier">int, optional (default=-1)</span></dt><dd><p>Hard limit on iterations within solver, or -1 for no limit.</p>
</dd>
<dt><strong>decision_function_shape</strong><span class="classifier">‘ovo’, ‘ovr’, default=’ovr’</span></dt><dd><p>Whether to return a one-vs-rest (‘ovr’) decision function of shape
(n_samples, n_classes) as all other classifiers, or the original
one-vs-one (‘ovo’) decision function of libsvm which has shape
(n_samples, n_classes * (n_classes - 1) / 2).</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 0.19: </span>decision_function_shape is ‘ovr’ by default.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in version 0.17: </span><em>decision_function_shape=’ovr’</em> is recommended.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 0.17: </span>Deprecated <em>decision_function_shape=’ovo’ and None</em>.</p>
</div>
</dd>
<dt><strong>break_ties</strong><span class="classifier">bool, optional (default=False)</span></dt><dd><p>If true, <code class="docutils literal notranslate"><span class="pre">decision_function_shape='ovr'</span></code>, and number of classes &gt; 2,
<a class="reference internal" href="../../glossary.html#term-predict"><span class="xref std std-term">predict</span></a> will break ties according to the confidence values of
<a class="reference internal" href="../../glossary.html#term-decision-function"><span class="xref std std-term">decision_function</span></a>; otherwise the first class among the tied
classes is returned. Please note that breaking ties comes at a
relatively high computational cost compared to a simple predict.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 0.22.</span></p>
</div>
</dd>
<dt><strong>random_state</strong><span class="classifier">int, RandomState instance or None, optional (default=None)</span></dt><dd><p>The seed of the pseudo random number generator used when shuffling
the data for probability estimates. If int, random_state is the seed
used by the random number generator; If RandomState instance,
random_state is the random number generator; If None, the random
number generator is the RandomState instance used by <code class="docutils literal notranslate"><span class="pre">np.random</span></code>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Attributes</dt>
<dd class="field-even"><dl>
<dt><strong>support_</strong><span class="classifier">array-like of shape (n_SV)</span></dt><dd><p>Indices of support vectors.</p>
</dd>
<dt><strong>support_vectors_</strong><span class="classifier">array-like of shape (n_SV, n_features)</span></dt><dd><p>Support vectors.</p>
</dd>
<dt><strong>n_support_</strong><span class="classifier">array-like, dtype=int32, shape = [n_class]</span></dt><dd><p>Number of support vectors for each class.</p>
</dd>
<dt><strong>dual_coef_</strong><span class="classifier">array, shape = [n_class-1, n_SV]</span></dt><dd><p>Coefficients of the support vector in the decision function.
For multiclass, coefficient for all 1-vs-1 classifiers.
The layout of the coefficients in the multiclass case is somewhat
non-trivial. See the section about multi-class classification in
the SVM section of the User Guide for details.</p>
</dd>
<dt><strong>coef_</strong><span class="classifier">array, shape = [n_class * (n_class-1) / 2, n_features]</span></dt><dd><p>Weights assigned to the features (coefficients in the primal
problem). This is only available in the case of a linear kernel.</p>
<p><code class="docutils literal notranslate"><span class="pre">coef_</span></code> is readonly property derived from <code class="docutils literal notranslate"><span class="pre">dual_coef_</span></code> and
<code class="docutils literal notranslate"><span class="pre">support_vectors_</span></code>.</p>
</dd>
<dt><strong>intercept_</strong><span class="classifier">ndarray of shape (n_class * (n_class-1) / 2,)</span></dt><dd><p>Constants in decision function.</p>
</dd>
<dt><strong>classes_</strong><span class="classifier">array of shape (n_classes,)</span></dt><dd><p>The unique classes labels.</p>
</dd>
<dt><strong>fit_status_</strong><span class="classifier">int</span></dt><dd><p>0 if correctly fitted, 1 if the algorithm did not converge.</p>
</dd>
<dt><strong>probA_</strong><span class="classifier">ndarray, shape of (n_class * (n_class-1) / 2,)</span></dt><dd></dd>
<dt><strong>probB_</strong><span class="classifier">ndarray of shape (n_class * (n_class-1) / 2,)</span></dt><dd><p>If <code class="docutils literal notranslate"><span class="pre">probability=True</span></code>, it corresponds to the parameters learned in
Platt scaling to produce probability estimates from decision values.
If <code class="docutils literal notranslate"><span class="pre">probability=False</span></code>, it’s an empty array. Platt scaling uses the
logistic function
<code class="docutils literal notranslate"><span class="pre">1</span> <span class="pre">/</span> <span class="pre">(1</span> <span class="pre">+</span> <span class="pre">exp(decision_value</span> <span class="pre">*</span> <span class="pre">probA_</span> <span class="pre">+</span> <span class="pre">probB_))</span></code>
where <code class="docutils literal notranslate"><span class="pre">probA_</span></code> and <code class="docutils literal notranslate"><span class="pre">probB_</span></code> are learned from the dataset <a class="reference internal" href="#r9709ce4a60d3-2" id="id1"><span>[R9709ce4a60d3-2]</span></a>. For
more information on the multiclass case and training procedure see
section 8 of <a class="reference internal" href="#r9709ce4a60d3-1" id="id2"><span>[R9709ce4a60d3-1]</span></a>.</p>
</dd>
<dt><strong>class_weight_</strong><span class="classifier">ndarray of shape (n_class,)</span></dt><dd><p>Multipliers of parameter C of each class.
Computed based on the <code class="docutils literal notranslate"><span class="pre">class_weight</span></code> parameter.</p>
</dd>
<dt><strong>shape_fit_</strong><span class="classifier">tuple of int of shape (n_dimensions_of_X,)</span></dt><dd><p>Array dimensions of training vector <code class="docutils literal notranslate"><span class="pre">X</span></code>.</p>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="sklearn.svm.SVC.html#sklearn.svm.SVC" title="sklearn.svm.SVC"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SVC</span></code></a></dt><dd><p>Support Vector Machine for classification using libsvm.</p>
</dd>
<dt><a class="reference internal" href="sklearn.svm.LinearSVC.html#sklearn.svm.LinearSVC" title="sklearn.svm.LinearSVC"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LinearSVC</span></code></a></dt><dd><p>Scalable linear Support Vector Machine for classification using liblinear.</p>
</dd>
</dl>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r9709ce4a60d3-1"><span class="brackets"><a class="fn-backref" href="#id2">R9709ce4a60d3-1</a></span></dt>
<dd><p><a class="reference external" href="http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf">LIBSVM: A Library for Support Vector Machines</a></p>
</dd>
<dt class="label" id="r9709ce4a60d3-2"><span class="brackets"><a class="fn-backref" href="#id1">R9709ce4a60d3-2</a></span></dt>
<dd><p><a class="reference external" href="http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.41.1639">Platt, John (1999). “Probabilistic outputs for support vector
machines and comparison to regularizedlikelihood methods.”</a></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">X</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sklearn.svm</span> <span class="kn">import</span> <span class="n">NuSVC</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">clf</span> <span class="o">=</span> <span class="n">NuSVC</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">clf</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">NuSVC()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">clf</span><span class="o">.</span><span class="n">predict</span><span class="p">([[</span><span class="o">-</span><span class="mf">0.8</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">]]))</span>
<span class="go">[1]</span>
</pre></div>
</div>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.decision_function" title="sklearn.svm.NuSVC.decision_function"><code class="xref py py-obj docutils literal notranslate"><span class="pre">decision_function</span></code></a>(self, X)</p></td>
<td><p>Evaluates the decision function for the samples in X.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.fit" title="sklearn.svm.NuSVC.fit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fit</span></code></a>(self, X, y[, sample_weight])</p></td>
<td><p>Fit the SVM model according to the given training data.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.get_params" title="sklearn.svm.NuSVC.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>(self[, deep])</p></td>
<td><p>Get parameters for this estimator.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.predict" title="sklearn.svm.NuSVC.predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict</span></code></a>(self, X)</p></td>
<td><p>Perform classification on samples in X.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.score" title="sklearn.svm.NuSVC.score"><code class="xref py py-obj docutils literal notranslate"><span class="pre">score</span></code></a>(self, X, y[, sample_weight])</p></td>
<td><p>Return the mean accuracy on the given test data and labels.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#sklearn.svm.NuSVC.set_params" title="sklearn.svm.NuSVC.set_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_params</span></code></a>(self, \*\*params)</p></td>
<td><p>Set the parameters of this estimator.</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="sklearn.svm.NuSVC.__init__">
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">nu=0.5</em>, <em class="sig-param">kernel='rbf'</em>, <em class="sig-param">degree=3</em>, <em class="sig-param">gamma='scale'</em>, <em class="sig-param">coef0=0.0</em>, <em class="sig-param">shrinking=True</em>, <em class="sig-param">probability=False</em>, <em class="sig-param">tol=0.001</em>, <em class="sig-param">cache_size=200</em>, <em class="sig-param">class_weight=None</em>, <em class="sig-param">verbose=False</em>, <em class="sig-param">max_iter=-1</em>, <em class="sig-param">decision_function_shape='ovr'</em>, <em class="sig-param">break_ties=False</em>, <em class="sig-param">random_state=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/svm/_classes.py#L844"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self.  See help(type(self)) for accurate signature.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.decision_function">
<code class="sig-name descname">decision_function</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/svm/_base.py#L537"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.decision_function" title="Permalink to this definition">¶</a></dt>
<dd><p>Evaluates the decision function for the samples in X.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like, shape (n_samples, n_features)</span></dt><dd></dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like, shape (n_samples, n_classes * (n_classes-1) / 2)</span></dt><dd><p>Returns the decision function of the sample for each class
in the model.
If decision_function_shape=’ovr’, the shape is (n_samples,
n_classes).</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>If decision_function_shape=’ovo’, the function values are proportional
to the distance of the samples X to the separating hyperplane. If the
exact distances are required, divide the function values by the norm of
the weight vector (<code class="docutils literal notranslate"><span class="pre">coef_</span></code>). See also <a class="reference external" href="https://stats.stackexchange.com/questions/14876/interpreting-distance-from-hyperplane-in-svm">this question</a> for further details.
If decision_function_shape=’ovr’, the decision function is a monotonic
transformation of ovo decision function.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.fit">
<code class="sig-name descname">fit</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">y</em>, <em class="sig-param">sample_weight=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/svm/_base.py#L107"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Fit the SVM model according to the given training data.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">{array-like, sparse matrix}, shape (n_samples, n_features)</span></dt><dd><p>Training vectors, where n_samples is the number of samples
and n_features is the number of features.
For kernel=”precomputed”, the expected shape of X is
(n_samples, n_samples).</p>
</dd>
<dt><strong>y</strong><span class="classifier">array-like, shape (n_samples,)</span></dt><dd><p>Target values (class labels in classification, real numbers in
regression)</p>
</dd>
<dt><strong>sample_weight</strong><span class="classifier">array-like, shape (n_samples,)</span></dt><dd><p>Per-sample weights. Rescale C per sample. Higher weights
force the classifier to put more emphasis on these points.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>self</strong><span class="classifier">object</span></dt><dd></dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>If X and y are not C-ordered and contiguous arrays of np.float64 and
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.</p>
<p>If X is a dense array, then the other methods will not support sparse
matrices as input.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.get_params">
<code class="sig-name descname">get_params</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">deep=True</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L173"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.get_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Get parameters for this estimator.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>deep</strong><span class="classifier">bool, default=True</span></dt><dd><p>If True, will return the parameters for this estimator and
contained subobjects that are estimators.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>params</strong><span class="classifier">mapping of string to any</span></dt><dd><p>Parameter names mapped to their values.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.predict">
<code class="sig-name descname">predict</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/svm/_base.py#L568"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform classification on samples in X.</p>
<p>For an one-class model, +1 or -1 is returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">{array-like, sparse matrix}, shape (n_samples, n_features)</span></dt><dd><p>For kernel=”precomputed”, the expected shape of X is
[n_samples_test, n_samples_train]</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>y_pred</strong><span class="classifier">array, shape (n_samples,)</span></dt><dd><p>Class labels for samples in X.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.predict_log_proba">
<em class="property">property </em><code class="sig-name descname">predict_log_proba</code><a class="headerlink" href="#sklearn.svm.NuSVC.predict_log_proba" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute log probabilities of possible outcomes for samples in X.</p>
<p>The model need to have probability information computed at training
time: fit with attribute <code class="docutils literal notranslate"><span class="pre">probability</span></code> set to True.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like, shape (n_samples, n_features)</span></dt><dd><p>For kernel=”precomputed”, the expected shape of X is
[n_samples_test, n_samples_train]</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>T</strong><span class="classifier">array-like, shape (n_samples, n_classes)</span></dt><dd><p>Returns the log-probabilities of the sample for each class in
the model. The columns correspond to the classes in sorted
order, as they appear in the attribute <a class="reference internal" href="../../glossary.html#term-classes"><span class="xref std std-term">classes_</span></a>.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The probability model is created using cross validation, so
the results can be slightly different than those obtained by
predict. Also, it will produce meaningless results on very small
datasets.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.predict_proba">
<em class="property">property </em><code class="sig-name descname">predict_proba</code><a class="headerlink" href="#sklearn.svm.NuSVC.predict_proba" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute probabilities of possible outcomes for samples in X.</p>
<p>The model need to have probability information computed at training
time: fit with attribute <code class="docutils literal notranslate"><span class="pre">probability</span></code> set to True.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like, shape (n_samples, n_features)</span></dt><dd><p>For kernel=”precomputed”, the expected shape of X is
[n_samples_test, n_samples_train]</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>T</strong><span class="classifier">array-like, shape (n_samples, n_classes)</span></dt><dd><p>Returns the probability of the sample for each class in
the model. The columns correspond to the classes in sorted
order, as they appear in the attribute <a class="reference internal" href="../../glossary.html#term-classes"><span class="xref std std-term">classes_</span></a>.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The probability model is created using cross validation, so
the results can be slightly different than those obtained by
predict. Also, it will produce meaningless results on very small
datasets.</p>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.score">
<code class="sig-name descname">score</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">X</em>, <em class="sig-param">y</em>, <em class="sig-param">sample_weight=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L344"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.score" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the mean accuracy on the given test data and labels.</p>
<p>In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>X</strong><span class="classifier">array-like of shape (n_samples, n_features)</span></dt><dd><p>Test samples.</p>
</dd>
<dt><strong>y</strong><span class="classifier">array-like of shape (n_samples,) or (n_samples, n_outputs)</span></dt><dd><p>True labels for X.</p>
</dd>
<dt><strong>sample_weight</strong><span class="classifier">array-like of shape (n_samples,), default=None</span></dt><dd><p>Sample weights.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>score</strong><span class="classifier">float</span></dt><dd><p>Mean accuracy of self.predict(X) wrt. y.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="sklearn.svm.NuSVC.set_params">
<code class="sig-name descname">set_params</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">**params</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scikit-learn/scikit-learn/blob/5f3c3f037/sklearn/base.py#L205"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#sklearn.svm.NuSVC.set_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the parameters of this estimator.</p>
<p>The method works on simple estimators as well as on nested objects
(such as pipelines). The latter have parameters of the form
<code class="docutils literal notranslate"><span class="pre">&lt;component&gt;__&lt;parameter&gt;</span></code> so that it’s possible to update each
component of a nested object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>**params</strong><span class="classifier">dict</span></dt><dd><p>Estimator parameters.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>self</strong><span class="classifier">object</span></dt><dd><p>Estimator instance.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

</dd></dl>

<div class="section" id="examples-using-sklearn-svm-nusvc">
<h2>Examples using <code class="docutils literal notranslate"><span class="pre">sklearn.svm.NuSVC</span></code><a class="headerlink" href="#examples-using-sklearn-svm-nusvc" title="Permalink to this headline">¶</a></h2>
<div class="sphx-glr-thumbcontainer" tooltip="Perform binary classification using non-linear SVC with RBF kernel. The target to predict is a ..."><div class="figure align-default" id="id5">
<img alt="../../_images/sphx_glr_plot_svm_nonlinear_thumb.png" src="../../_images/sphx_glr_plot_svm_nonlinear_thumb.png" />
<p class="caption"><span class="caption-text"><a class="reference internal" href="../../auto_examples/svm/plot_svm_nonlinear.html#sphx-glr-auto-examples-svm-plot-svm-nonlinear-py"><span class="std std-ref">Non-linear SVM</span></a></span><a class="headerlink" href="#id5" title="Permalink to this image">¶</a></p>
</div>
</div><div class="clearer"></div></div>
</div>


      </div>
    <div class="container">
      <footer class="sk-content-footer">
            &copy; 2007 - 2019, scikit-learn developers (BSD License).
          <a href="../../_sources/modules/generated/sklearn.svm.NuSVC.rst.txt" rel="nofollow">Show this page source</a>
      </footer>
    </div>
  </div>
</div>
<script src="../../_static/js/vendor/bootstrap.min.js"></script>

<script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-22606712-2', 'auto');
    ga('set', 'anonymizeIp', true);
    ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>


<script>
$(document).ready(function() {
    /* Add a [>>>] button on the top-right corner of code samples to hide
     * the >>> and ... prompts and the output and thus make the code
     * copyable. */
    var div = $('.highlight-python .highlight,' +
                '.highlight-python3 .highlight,' +
                '.highlight-pycon .highlight,' +
		'.highlight-default .highlight')
    var pre = div.find('pre');

    // get the styles from the current theme
    pre.parent().parent().css('position', 'relative');
    var hide_text = 'Hide prompts and outputs';
    var show_text = 'Show prompts and outputs';

    // create and add the button to all the code blocks that contain >>>
    div.each(function(index) {
        var jthis = $(this);
        if (jthis.find('.gp').length > 0) {
            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
            jthis.prepend(button);
        }
        // tracebacks (.gt) contain bare text elements that need to be
        // wrapped in a span to work with .nextUntil() (see later)
        jthis.find('pre:has(.gt)').contents().filter(function() {
            return ((this.nodeType == 3) && (this.data.trim().length > 0));
        }).wrap('<span>');
    });

    // define the behavior of the button when it's clicked
    $('.copybutton').click(function(e){
        e.preventDefault();
        var button = $(this);
        if (button.data('hidden') === 'false') {
            // hide the code output
            button.parent().find('.go, .gp, .gt').hide();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
            button.css('text-decoration', 'line-through');
            button.attr('title', show_text);
            button.data('hidden', 'true');
        } else {
            // show the code output
            button.parent().find('.go, .gp, .gt').show();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
            button.css('text-decoration', 'none');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
        }
    });

	/*** Add permalink buttons next to glossary terms ***/
	$('dl.glossary > dt[id]').append(function() {
		return ('<a class="headerlink" href="#' +
			    this.getAttribute('id') +
			    '" title="Permalink to this term">¶</a>');
	});
  /*** Hide navbar when scrolling down ***/
  // Returns true when headerlink target matches hash in url
  (function() {
    hashTargetOnTop = function() {
        var hash = window.location.hash;
        if ( hash.length < 2 ) { return false; }

        var target = document.getElementById( hash.slice(1) );
        if ( target === null ) { return false; }

        var top = target.getBoundingClientRect().top;
        return (top < 2) && (top > -2);
    };

    // Hide navbar on load if hash target is on top
    var navBar = document.getElementById("navbar");
    var navBarToggler = document.getElementById("sk-navbar-toggler");
    var navBarHeightHidden = "-" + navBar.getBoundingClientRect().height + "px";
    var $window = $(window);

    hideNavBar = function() {
        navBar.style.top = navBarHeightHidden;
    };

    showNavBar = function() {
        navBar.style.top = "0";
    }

    if (hashTargetOnTop()) {
        hideNavBar()
    }

    var prevScrollpos = window.pageYOffset;
    hideOnScroll = function(lastScrollTop) {
        if (($window.width() < 768) && (navBarToggler.getAttribute("aria-expanded") === 'true')) {
            return;
        }
        if (lastScrollTop > 2 && (prevScrollpos <= lastScrollTop) || hashTargetOnTop()){
            hideNavBar()
        } else {
            showNavBar()
        }
        prevScrollpos = lastScrollTop;
    };

    /*** high preformance scroll event listener***/
    var raf = window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame;
    var lastScrollTop = $window.scrollTop();

    if (raf) {
        loop();
    }

    function loop() {
        var scrollTop = $window.scrollTop();
        if (lastScrollTop === scrollTop) {
            raf(loop);
            return;
        } else {
            lastScrollTop = scrollTop;
            hideOnScroll(lastScrollTop);
            raf(loop);
        }
    }
  })();
});

</script>
    
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
    
</body>
</html>